home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / ham / sattrk31.tgz / sattrack-3.1.tar / SatTrack / src / sattrack / satargs.c next >
C/C++ Source or Header  |  1995-03-16  |  10KB  |  284 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*  Title       : satargs.c                                                   */
  4. /*  Author      : Manfred Bester                                              */
  5. /*  Date        : 21Nov94                                                     */
  6. /*  Last change : 15Mar95                                                     */
  7. /*                                                                            */
  8. /*  Synopsis    : Routines for command line parsing.                          */
  9. /*                                                                            */
  10. /*                                                                            */
  11. /*  SatTrack is Copyright (c) 1992, 1993, 1994, 1995 by Manfred Bester.       */
  12. /*  All Rights Reserved.                                                      */
  13. /*                                                                            */
  14. /*  Permission to use, copy, and distribute SatTrack and its documentation    */
  15. /*  in its entirety for educational, research and non-profit purposes,        */
  16. /*  without fee, and without a written agreement is hereby granted, provided  */
  17. /*  that the above copyright notice and the following three paragraphs appear */
  18. /*  in all copies. SatTrack may be modified for personal purposes, but        */
  19. /*  modified versions may NOT be distributed without prior consent of the     */
  20. /*  author.                                                                   */
  21. /*                                                                            */
  22. /*  Permission to incorporate this software into commercial products may be   */
  23. /*  obtained from the author, Dr. Manfred Bester, 1636 M. L. King Jr. Way,    */
  24. /*  Berkeley, CA 94709, USA. Note that distributing SatTrack 'bundled' in     */
  25. /*  with ANY product is considered to be a 'commercial purpose'.              */
  26. /*                                                                            */
  27. /*  IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, */
  28. /*  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF   */
  29. /*  THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED  */
  30. /*  OF THE POSSIBILITY OF SUCH DAMAGE.                                        */
  31. /*                                                                            */
  32. /*  THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT      */
  33. /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A   */
  34. /*  PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"      */
  35. /*  BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, */
  36. /*  UPDATES, ENHANCEMENTS, OR MODIFICATIONS.                                  */
  37. /*                                                                            */
  38. /******************************************************************************/
  39.  
  40. #include <stdio.h>
  41. #include <string.h>
  42.  
  43. #ifndef STDLIB
  44. #include <stdlib.h>
  45. #endif
  46.  
  47. #include "satglobalsx.h"
  48. #include "sattrack.h"
  49.  
  50. #ifdef HPTERM
  51. #include "hpterm.h"
  52. #else
  53. #include "vt100.h"
  54. #endif
  55.  
  56. /******************************************************************************/
  57. /*                                                                            */
  58. /* checkArguments: checks if command line arguments are passed to main        */
  59. /*                                                                            */
  60. /******************************************************************************/
  61.  
  62. void checkArguments(argC,argV)
  63.  
  64. int  argC;
  65. char *argV[];
  66.  
  67. {
  68.     int  i, error, argCount;
  69.     char defaultsFileStr[80];
  70.  
  71.     batchModeFlag    = FALSE;
  72.     debugFlag        = FALSE;
  73.     defaultsFileFlag = FALSE;
  74.     graphicsFlag     = FALSE;
  75.     modelFlag        = FALSE;
  76.     quickStartFlag   = FALSE;
  77.     timeZoneFlag     = FALSE;
  78.     verboseFlag      = FALSE;
  79.     error            = FALSE;
  80.  
  81.     if (argC >= 2)
  82.     {
  83.         argCount = 1;
  84.  
  85.         for (i = 1; i < argC; i++)
  86.         {
  87.             upperCase(argV[i]);
  88.  
  89.             if (!strncmp(argV[i],BATCH,2) && (int) strlen(argV[i]) == 2)
  90.             {
  91.                 batchModeFlag = TRUE;
  92.                 argCount++;
  93.             }
  94.  
  95.             if (!strncmp(argV[i],DEBUG,2) && (int) strlen(argV[i]) == 2)
  96.             {
  97.                 debugFlag = TRUE;
  98.                 argCount++;
  99.             }
  100.  
  101.             if (!strncmp(argV[i],DEFFILE,2) && (int) strlen(argV[i]) <= 4)
  102.             {
  103.                 defaultsFileFlag = TRUE;
  104.                 strcpy(defaultsFileStr,argV[i]);
  105.                 argCount++;
  106.             }
  107.  
  108.             if (!strncmp(argV[i],GRAPH,2) && (int) strlen(argV[i]) == 2)
  109.             {
  110.                 graphicsFlag = TRUE;
  111.                 argCount++;
  112.             }
  113.  
  114.             if (!strncmp(argV[i],MODEL,2) && (int) strlen(argV[i]) == 2)
  115.             {
  116.                 modelFlag = TRUE;
  117.                 argCount++;
  118.             }
  119.  
  120.             if (!strncmp(argV[i],QUICK,2) && (int) strlen(argV[i]) == 2)
  121.             {
  122.                 quickStartFlag = TRUE;
  123.                 argCount++;
  124.             }
  125.  
  126.             if (!strncmp(argV[i],TIMEZONE,2) && (int) strlen(argV[i]) == 2)
  127.             {
  128.                 timeZoneFlag = TRUE;
  129.                 argCount++;
  130.             }
  131.  
  132.             if (!strncmp(argV[i],VERBOSE,2) && (int) strlen(argV[i]) == 2)
  133.             {
  134.                 verboseFlag = TRUE;
  135.                 argCount++;
  136.             }
  137.         }
  138.  
  139.         if (argC != argCount && !batchModeFlag)
  140.         {
  141.             nl();
  142.             printf("%s %s\n",sattrName,sattrVersion);
  143.             doBeep();
  144.             printf("Usage: sattrack [-b] [-d] [-fn] [-g] [-m] [-q] [-t] [-v]");
  145.             printf("\n\n");
  146.             exit(-1);
  147.         }
  148.     } 
  149.  
  150.     if (batchModeFlag)
  151.     {
  152.         debugFlag        = FALSE;
  153.         defaultsFileFlag = FALSE;
  154.         graphicsFlag     = FALSE;
  155.         modelFlag        = FALSE;
  156.         quickStartFlag   = FALSE;
  157.         timeZoneFlag     = FALSE;
  158.         verboseFlag      = FALSE;
  159.  
  160.         if (argC != 14)
  161.         {
  162.             nl();
  163.             printf("%s %s Batch Mode",sattrName,sattrVersion);
  164.             nl(); doBeep(); nl(); reverseBlink();
  165.             printf(" Number of command line arguments is wrong \n");
  166.             normal(); nl();
  167.  
  168.             error = TRUE;
  169.         }
  170.  
  171.         if (error)
  172.         {
  173.             printf("Usage:    sattrack -b ");
  174.             underline();
  175.             printf("time-zone");
  176.             normal();
  177.             bl();
  178.             underline();
  179.             printf("ground-station");
  180.             normal();
  181.             bl();
  182.             underline();
  183.             printf("satellite");
  184.             normal();
  185.             bl();
  186.             underline();
  187.             printf("tle-file");
  188.             normal();
  189.             bl();
  190.             underline();
  191.             printf("tle-type");
  192.             normal();
  193.             nl();
  194.             printf("          ");
  195.             underline();
  196.             printf("prediction-type");
  197.             normal();
  198.             bl();
  199.             underline();
  200.             printf("start-date");
  201.             normal();
  202.             bl();
  203.             underline();
  204.             printf("start-time");
  205.             normal();
  206.             bl();
  207.             underline();
  208.             printf("time-step [s]");
  209.             normal();
  210.             bl();
  211.             underline();
  212.             printf("duration [d]");
  213.             normal();
  214.             nl();
  215.             printf("          ");
  216.             underline();
  217.             printf("min-elev [deg]");
  218.             normal();
  219.             bl();
  220.             printf("[no]hardcopy");
  221.             nl(); nl();
  222.  
  223.             printf("Examples: ");
  224.             printf("sattrack -b UTC Berkeley ");
  225.             printf("16609 tlex.dat nasa shortpr\n");
  226.             printf("          ");
  227.             printf("now now auto 6 0 hardcopy\n");
  228.             nl();
  229.             printf("          ");
  230.             printf("sattrack -b EST Melbourne,_FL,_USA ");
  231.             printf("sts-55 sts.dat norad longpr\n");
  232.             printf("          ");
  233.             printf("24Apr93 12:0:0 20 1.5 0 nohardcopy\n");
  234.             nl();
  235.             exit(-1);
  236.         }
  237.  
  238.         else
  239.         {
  240.             strcpy(batchTimeZone,argV[2]);
  241.             strcpy(batchSiteName,argV[3]);
  242.             strcpy(batchSatName,argV[4]);
  243.             strcpy(batchTleFile,argV[5]);
  244.             strcpy(batchTleType,argV[6]);
  245.             strcpy(batchPredType,argV[7]);
  246.             strcpy(batchStartDate,argV[8]);
  247.             strcpy(batchStartTime,argV[9]);
  248.             strcpy(batchStepTime,argV[10]);
  249.             strcpy(batchDuration,argV[11]);
  250.             strcpy(batchMinElev,argV[12]);
  251.             strcpy(batchHardcopy,argV[13]);
  252.  
  253.             replaceBlanks(batchSiteName);
  254.             replaceBlanks(batchSatName);
  255.         }
  256.  
  257.     }
  258.  
  259.     if (defaultsFileFlag)
  260.     {
  261.         clipString(defaultsFileStr,2);
  262.         defaultsFileNum = atoi(defaultsFileStr);
  263.  
  264.         if (defaultsFileNum < 0 || defaultsFileNum > 99 || 
  265.             (int) strlen(defaultsFileStr) > 2 || 
  266.             (defaultsFileNum < 10 && (int) strlen(defaultsFileStr) > 1))
  267.         {
  268.             nl();
  269.             printf("%s %s\n",sattrName,sattrVersion);
  270.             doBeep();
  271.             printf("\nUsage: sattrack [-fn]  (n = 0,...,99)\n\n");
  272.             exit(-1);
  273.         }
  274.     }
  275.  
  276.     return;
  277. }
  278.  
  279. /******************************************************************************/
  280. /*                                                                            */
  281. /* End of function block satargs.c                                            */
  282. /*                                                                            */
  283. /******************************************************************************/
  284.